#include <bits/stdc++.h>
using namespace std;
#define ll long long
int jjpow(int, int);
int jjC(ll, ll);
const int MOD = 1e9 + 7;

struct node{
    vector<int>adjustsNode;
    int color = 0;
};

int n, m, a, b, jjvisit[25];
ll ret;
vector<int>connectGraph;
node vertices[25];

void dfs(int x){
    connectGraph.push_back(x);
    jjvisit[x] = 1;
    for(int i: vertices[x].adjustsNode){
        if(jjvisit[i] == 0)
            dfs(x);
    }
}

int valid(int index, int color){
    for(int i: vertices[index].adjustsNode){
        if(vertices[i].color == color)
            return 0;
    }
    return 1;
}

void do_color(int level){
    if(level == connectGraph.size()){
        ++ret;
        return;
    }
    for(int i = 1; i <= 3; ++i){
        if(valid(connectGraph[level], i)){
            vertices[connectGraph[level]].color = i;
            do_color(level + 1);
            vertices[connectGraph[level]].color = 0;
        }
    }
}

void solve(){
    ll ans = 1;
    for(int i = 1; i <= n; ++i){
        if(jjvisit[i] == 0){
            connectGraph.clear();
            dfs(i);
            ret = 0;
            do_color(0);
            ans *= ret;
        }
    }
    printf("%lld\n", ans);
}

void init(){
    scanf("%d%d", &n, &m);
    /* for(int i = 0; i < n; ++i) */
    /*     vertices[i].index = i + 1; */
    for(int i = 0; i < m; ++i){
        scanf("%d%d", &a, &b);
        vertices[a].adjustsNode.push_back(b);
        vertices[b].adjustsNode.push_back(a);
    }
}

int main(){
    #ifndef ONLINE_JUDGE
        auto start_clock = clock();
        //freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    #endif
    
    init();
    solve();
    
    #ifndef ONLINE_JUDGE
        auto end_clock = clock();
        //cout<<"runtime: "<<end_clock - start_clock<<"ms"<<endl;
    #endif
    return 0;
}

int jjpow(int a, int b){
    if(b == 2)return (a * a)%MOD;
    if(b == 1)return a;
    int ret1 = a, ret2 = a;
    int cnt1 = log(b)/log(2);
    int cnt2 = b - pow(2, cnt1);
    ret1 = jjpow(a, cnt2);
    for(int i = 0; i < cnt1; ++i){
        ret2 = (ret2 * ret2)%MOD;
    }
    return (ret1 * ret2)%MOD;
}

int jjC(ll a, ll b){
    int ret = 1, tmp = 1;
    for(int i = a; i > a - b; --i){
        ret = (ret * i)%MOD;
    }
    for(int i = 2; i <= b; ++i){
        tmp = (tmp * i)%MOD;
    }
    return ret/tmp;
}
